Column

U.S. Confirmed Cases

U.S. Deaths

View Confirmed Cases and Deaths by State

---
title: "Map Dashboard"
output: 
 flexdashboard::flex_dashboard:
   orientation: rows
   vertical_layout: fill
   source_code: embed
runtime: shiny
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(eval = T, echo = F, message = F, cache=F)

library(flexdashboard)
library(tidyverse)
library(plotly)
library(readxl)
library(here)
library(knitr)
library(maps)
library(usmap)
library(shiny)
library(lubridate)

```

```{r}
covid.data2 <- read.csv(here::here("us_covid_joined_07062021.csv")) 

covid.data.7 <- subset(covid.data2, month=="7")
covid.data.705 <- subset(covid.data.7, day=="5")
covid.data.70521 <- subset(covid.data.705, year=="21" )
```


Column {data-width=650}
-----------------------------------------------------------------------

### U.S. Confirmed Cases



```{r}
confirmed <- plot_usmap(regions="states",data = covid.data.70521, 
           values = "confirmed",
           size = .05,
           theme = theme_minimal()) +
      theme(axis.title = element_blank(),
         axis.ticks = element_blank(),
         axis.text = element_blank()) +
   labs(fill = "confirmed") +
   viridis::scale_fill_viridis()
ggplotly(confirmed)
```


### U.S. Deaths
```{r}
deaths <- plot_usmap(data = covid.data.70521, 
           values = "deaths",
           size = .05,
           theme = theme_minimal()) +
      theme(axis.title = element_blank(),
         axis.ticks = element_blank(),
         axis.text = element_blank()) +
   labs(fill = "deaths") +
   viridis::scale_fill_viridis()

ggplotly(deaths)
```



### View Confirmed Cases and Deaths by State

```{r}
#states
states <-force(state.abb)
selectInput("statechoice", # name of the widget, will be used later as input
            label = ("Select State to View"), # label the widget
           choices = states, # use the states dataset as choices in dropdown
           selected = "CT") # default selected is CA (something must be slected)





renderPlot({ # render the interactive plot - if you don't wrap in a render statement, the widgets won't change anything
plot_usmap(include = input$statechoice, # show only selected state using the input from widget 
           data = covid.data.70521, 
           values = "confirmed", 
           theme = theme_minimal()) +
      theme(axis.title = element_blank(),
         axis.ticks = element_blank(),
         axis.text = element_blank()) +
   labs(fill = "confirmed") +
   viridis::scale_fill_viridis()
   # +ggplotly()
})
```


```{r}
renderPlot({ # render the interactive plot - if you don't wrap in a render statement, the widgets won't change anything
plot_usmap(include = input$statechoice, # show only selected state using the input from widget 
           data = covid.data.70521, 
           values = "deaths", 
           theme = theme_minimal()) +
      theme(axis.title = element_blank(),
         axis.ticks = element_blank(),
         axis.text = element_blank()) +
   labs(fill = "deaths") +
   viridis::scale_fill_viridis()
   # +ggplotly()
})
```